home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
SourceCode
/
daymisckit_proj
/
Headers
/
daymisckit
/
DAYLogFile.h
< prev
next >
Wrap
Text File
|
1995-06-12
|
2KB
|
71 lines
//
// DAYLogFile.h -- a generic class to simplify keeping an atomic lock file
// Written by Don Yacktman (c) 1993 by Don Yacktman.
// Version 1.0. All rights reserved.
//
// This is a free object! Contact the author for the latest version.
// Don Yacktman, 4279 N. Ivy Lane, Provo, UT, 84604
// e-mail: Don_Yacktman@byu.edu
//
// See DAYLogFile.m for details of the software license.
//
#import <appkit/appkit.h>
@interface DAYLogFile:Object <NXTransport>
{
id lockFile, fileName, lastLine;
int repeats;
BOOL fileOpen, special; // special == YES if using stdout or stderr
FILE *file; // only valid if fileOpen == YES
}
- init;
- fileName;
// Changing the name of the file will close the current log, if open,
// and stop using a lock file (see below). Pass in a DAYString for
// the file name.
- setFileName:aString;
// If you pass in a DAYLockFile, then the log file will be locked
// by using the DAYLockFile you passed in. If more than one process
// can affect a log file, then you should make sure that all those
// processes use a lock file! If you don't set up a lock file,
// then by default none will be used.
- setLockFile:newLockFile;
// Use this method to add an arbitrary string to the log file --
// it opens and closes the file automatically, obtaining locks if needed.
// This is better than sitting for a long time holding locks.
// returns YES is successful, NO otherwise.
- (BOOL)addLineToLogFile:aString;
// These are for use when you have multiple things to add and you wish to
// keep the file open until you are done writing all of it. Function is
// rather obvious. Return YES if successful, no otherwise.
- (BOOL)openFile; // always opened for APPENDING. Created if non-existent.
- (BOOL)appendToLogFile:aString andFlush:(BOOL)flushFlag;
- (BOOL)closeFile;
// -openFile and -closeFile have no effect if you use these:
- usestdout;
- usestderr;
// These are pretty obvious. A copy will not be an opened file nor will it
// have a lock, regardless of the state of the receiver of the -copy.
- copy;
- read:(NXTypedStream *)stream;
- write:(NXTypedStream *)stream;
// Use these if you must...
- (FILE *)file;
- (BOOL)fileIsOpen;
- (BOOL)special;
- lockFile;
// Handles closing files and removing locks if necessary.
- free;
@end